import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import _uniqBy from "lodash/uniqBy";
import _pullAllBy from "lodash/pullAllBy";
import _isNil from "lodash/isNil";
import _isInteger from "lodash/isInteger";
import _isEmpty from "lodash/isEmpty";
import _find from "lodash/find";

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _class;

import React, { PureComponent } from 'react';
import { Button, Table } from 'antd';
import { Bind } from 'lodash-decorators';
import uuidv4 from 'uuid/v4';
import { getCurrentOrganizationId, tableScrollWidth } from 'utils/utils';
import notification from 'utils/notification';
import { operatorRender } from 'utils/renderer';
import intl from 'utils/intl';
import { VERSION_IS_OP } from 'utils/config';
import Drawer from "../Drawer"; // import OrganizationModal from './Organization';

import QueryForm from "./QueryForm";
import EditableRow from "./EditableRow";
import EditableCell from "./EditableCell";
import styles from "./index.less?modules";
var EditableContext = React.createContext();
var currentTenantId = getCurrentOrganizationId(); // const EditableRow = ({ form, index, ...props }) => {
//   return (
//     <EditableContext.Provider value={form}>
//       <tr {...props} />
//     </EditableContext.Provider>
//   );
// };
// const EditableFormRow = Form.create({ fieldNameProp: null })(EditableRow);

function getCodeTag(value) {
  var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  var result;

  if (value && !_isEmpty(code)) {
    var codeList = code.filter(function (n) {
      return n.value === value;
    });

    if (!_isEmpty(codeList)) {
      result = codeList[0].tag;
    }
  }

  return result;
}

function assignResourceLevel() {
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var roleDatasource = arguments.length > 1 ? arguments[1] : undefined;
  var recordOrganizationId = arguments.length > 2 ? arguments[2] : undefined;
  var parentRoleAssignLevel = arguments.length > 3 ? arguments[3] : undefined;
  var newOptions = options;
  var parentRoleAssignLevelTag = Number(getCodeTag(parentRoleAssignLevel, options)); // if (roleDatasource.tenantId !== 0) {

  newOptions = options.filter(function (o) {
    return o.value !== 'site';
  }); // } else {
  //   newOptions = options.filter(o => o.value === 'site');
  // }

  return newOptions.filter(function (o) {
    return Number(o.tag) >= parentRoleAssignLevelTag;
  }); // roleDatasource.tenantId !== recordOrganizationId
  // ? newOptions.filter(o => Number(o.tag) >= parentRoleAssignLevelTag)
  // newOptions;
}

var Members = (_dec = Bind(), _dec2 = Bind(), _dec3 = Bind(), _dec4 = Bind(), _dec5 = Bind(), _dec6 = Bind(), _dec7 = Bind(), _dec8 = Bind(), _dec9 = Bind(), _dec10 = Bind(), (_class = /*#__PURE__*/function (_PureComponent) {
  _inherits(Members, _PureComponent);

  var _super = _createSuper(Members);

  function Members(props) {
    var _this;

    _classCallCheck(this, Members);

    _this = _super.call(this, props);
    _this.state = {
      selectedRows: [],
      dataSource: [],
      pagination: {},
      editingRows: [] // organizationModalVisible: false,
      // organizationModalDataSource: [],
      // currentEditingRow: {},

    };
    _this.onDrawerClose = _this.onDrawerClose.bind(_assertThisInitialized(_this));
    _this.fetchDataSource = _this.fetchDataSource.bind(_assertThisInitialized(_this));
    return _this;
  }

  _createClass(Members, [{
    key: "getSnapshotBeforeUpdate",
    value: function getSnapshotBeforeUpdate(prevProps) {
      var _this$props = this.props,
          visible = _this$props.visible,
          roleDatasource = _this$props.roleDatasource;
      return visible && _isInteger(roleDatasource.id) && roleDatasource.id !== prevProps.roleDatasource.id;
    }
  }, {
    key: "componentDidUpdate",
    value: function componentDidUpdate(prevProps, prevState, snapshot) {
      if (snapshot) {
        this.fetchDataSource();
      }
    }
  }, {
    key: "onDrawerClose",
    value: function onDrawerClose() {
      var _this$props$close = this.props.close,
          close = _this$props$close === void 0 ? function (e) {
        return e;
      } : _this$props$close;
      this.setState({
        dataSource: [],
        selectedRows: [],
        pagination: {},
        editingRows: []
      });
      close();
    }
  }, {
    key: "onTableSelectedRowChange",
    value: function onTableSelectedRowChange(selectedRowKeys, selectedRows) {
      this.setState({
        selectedRows: selectedRows
      });
    }
  }, {
    key: "onTableChange",
    value: function onTableChange(pagination) {
      var _this$queryForm$getFi = this.queryForm.getFieldsValue,
          getFieldsValue = _this$queryForm$getFi === void 0 ? function (e) {
        return e;
      } : _this$queryForm$getFi;
      var _pagination$current = pagination.current,
          current = _pagination$current === void 0 ? 1 : _pagination$current,
          _pagination$pageSize = pagination.pageSize,
          pageSize = _pagination$pageSize === void 0 ? 10 : _pagination$pageSize;
      this.fetchDataSource(_objectSpread(_objectSpread({}, getFieldsValue()), {}, {
        page: current - 1,
        size: pageSize
      }));
    }
  }, {
    key: "fetchDataSource",
    value: function fetchDataSource() {
      var _this2 = this;

      var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var _this$props$handleFet = this.props.handleFetchData,
          handleFetchData = _this$props$handleFet === void 0 ? function (e) {
        return e;
      } : _this$props$handleFet;
      handleFetchData(_objectSpread({
        page: 0,
        size: 10
      }, params)).then(function (res) {
        if (res) {
          var dataSource = res.dataSource,
              pagination = res.pagination;

          _this2.setState({
            dataSource: dataSource,
            pagination: pagination,
            editingRows: []
          });
        }
      });
    }
  }, {
    key: "add",
    value: function add() {
      var _this$state = this.state,
          editingRows = _this$state.editingRows,
          dataSource = _this$state.dataSource;
      var _this$props$roleDatas = this.props.roleDatasource,
          roleDatasource = _this$props$roleDatas === void 0 ? {} : _this$props$roleDatas;
      var item = {
        key: uuidv4()
      }; // if (roleDatasource.tenantId === 0) {
      //   item.organizationId = roleDatasource.tenantId;
      //   item.tenantName = roleDatasource.tenantName;
      //   // item.assignLevel = 'site';
      //   // item.assignLevelMeaning = getCodeMeaning('site', resourceLevel);
      //   // item.assignLevelValue = 0;
      //   // item.assignLevelValueMeaning = roleDatasource.tenantName;
      // }

      if (roleDatasource.level === 'site') {
        item.assignLevel = 'organization';
        item.assignLevelValue = roleDatasource.tenantId;
        item.assignLevelValueMeaning = roleDatasource.tenantName; // 之前的逻辑
        // item.organizationId = roleDatasource.tenantId;
        // item.tenantName = roleDatasource.tenantName;
        // item.assignLevel = 'organization';
        // // item.assignLevelMeaning = getCodeMeaning('site', resourceLevel);
        // item.assignLevelValue = 0;
        // // item.assignLevelValueMeaning = roleDatasource.tenantName;
      }

      if (!_isNil(roleDatasource.parentRoleAssignUnitId)) {
        item.assignLevel = 'org';
      }

      if (currentTenantId !== 0 && VERSION_IS_OP) {
        item.organizationId = roleDatasource.tenantId;
        item.tenantName = roleDatasource.tenantName;
        item.assignLevel = 'organization'; // item.assignLevelMeaning = getCodeMeaning('site', resourceLevel);

        item.assignLevelValue = 0; // item.assignLevelValueMeaning = roleDatasource.tenantName;
      }

      this.setState({
        dataSource: [item].concat(dataSource),
        editingRows: _uniqBy(editingRows.concat(item), 'key')
      });
    }
  }, {
    key: "deleteRow",
    value: function deleteRow() {
      var _this3 = this;

      var _this$state2 = this.state,
          selectedRows = _this$state2.selectedRows,
          dataSource = _this$state2.dataSource,
          pagination = _this$state2.pagination;
      var _this$props2 = this.props,
          _this$props2$handleDe = _this$props2.handleDelete,
          handleDelete = _this$props2$handleDe === void 0 ? function (e) {
        return e;
      } : _this$props2$handleDe,
          _this$props2$roleData = _this$props2.roleDatasource,
          roleDatasource = _this$props2$roleData === void 0 ? {} : _this$props2$roleData;
      var current = pagination.current,
          pageSize = pagination.pageSize;
      var _this$queryForm$getFi2 = this.queryForm.getFieldsValue,
          getFieldsValue = _this$queryForm$getFi2 === void 0 ? function (e) {
        return e;
      } : _this$queryForm$getFi2;
      var data = selectedRows.filter(function (o) {
        return _isInteger(Number(o.key));
      });
      this.setState({
        dataSource: _pullAllBy(_toConsumableArray(dataSource), selectedRows.filter(function (o) {
          return !_isInteger(Number(o.key));
        }, 'key'))
      });

      if (!_isEmpty(data)) {
        handleDelete(data.map(function (n) {
          return {
            memberId: n.id,
            roleId: roleDatasource.id
          };
        }), function () {
          notification.success();

          _this3.fetchDataSource(_objectSpread({
            roleId: roleDatasource.id,
            page: current - 1,
            size: pageSize
          }, getFieldsValue()));
        });
      }
    }
  }, {
    key: "save",
    value: function save() {
      var _this4 = this;

      var _this$props3 = this.props,
          _this$props3$handleSa = _this$props3.handleSave,
          handleSave = _this$props3$handleSa === void 0 ? function (e) {
        return e;
      } : _this$props3$handleSa,
          roleDatasource = _this$props3.roleDatasource;
      var _this$state3 = this.state,
          _this$state3$dataSour = _this$state3.dataSource,
          dataSource = _this$state3$dataSour === void 0 ? [] : _this$state3$dataSour,
          _this$state3$editingR = _this$state3.editingRows,
          editingRows = _this$state3$editingR === void 0 ? [] : _this$state3$editingR;
      var tableRowForms = this.tableRowForms.map(function (o) {
        var item = editingRows.find(function (n) {
          return o.key === n.key;
        });
        return !_isEmpty(item) ? _objectSpread(_objectSpread({}, o), {}, {
          rowData: item
        }) : false;
      }).filter(Boolean);
      Promise.all(tableRowForms.map(function (o) {
        return new Promise(function (resolve, rejcet) {
          var _ref = o.row || {},
              _ref$validateFields = _ref.validateFields,
              validateFields = _ref$validateFields === void 0 ? function () {} : _ref$validateFields;

          validateFields(function (error, values) {
            if (!_isEmpty(error)) {
              rejcet(error);
            } else {
              resolve(_objectSpread(_objectSpread({}, o.rowData), values));
            }
          });
        });
      })).then(function () {
        var result = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
        var data = dataSource.map(function (n) {
          var newItem = result.find(function (o) {
            return o.key === n.key;
          });
          var item = !_isEmpty(newItem) ? newItem : n;
          var id = item.id,
              assignLevel = item.assignLevel,
              assignLevelValue = item.assignLevelValue;
          return {
            memberId: id,
            assignLevel: assignLevel,
            assignLevelValue: assignLevelValue,
            roleId: roleDatasource.id
          };
        });

        if (!_isEmpty(data)) {
          handleSave(data, false, function () {
            notification.success({
              message: intl.get("cpaas.common.notification.success.save").d('保存成功')
            });

            _this4.onDrawerClose();
          });
        }
      }).catch(function (e) {
        window.console.warn(e);
      }); // if (!isEmpty(dataSource.filter(o => !isEmpty(o.error)))) {
      //   return;
      // }
    }
  }, {
    key: "search",
    value: function search(params) {
      this.fetchDataSource(_objectSpread({
        page: 0,
        size: 10
      }, params));
    }
  }, {
    key: "getColumns",
    value: function getColumns(defaultColumns) {
      var _this5 = this;

      var _this$props4 = this.props,
          roleDatasource = _this$props4.roleDatasource,
          resourceLevel = _this$props4.resourceLevel,
          _this$props4$handleFe = _this$props4.handleFetchHrunitsTree,
          handleFetchHrunitsTree = _this$props4$handleFe === void 0 ? function (e) {
        return e;
      } : _this$props4$handleFe;
      var _this$state4 = this.state,
          editingRows = _this$state4.editingRows,
          _this$state4$dataSour = _this$state4.dataSource,
          dataSource = _this$state4$dataSour === void 0 ? [] : _this$state4$dataSour;
      var saveBtnTarget = this.saveBtn;

      var setRecord = function setRecord(newRecored) {
        _this5.setState({
          dataSource: dataSource.map(function (o) {
            return o.key === newRecored.key ? newRecored : o;
          })
        });
      };

      var getColumn = function getColumn(defaultColumn) {
        var dataIndex = defaultColumn.dataIndex,
            title = defaultColumn.title;
        return dataIndex !== 'realName' && dataIndex !== 'tenantName' ? _objectSpread(_objectSpread({}, defaultColumn), {}, {
          render: function render(text, record) {
            var isUpdate = _isInteger(Number(record.key));

            var editing = !_isEmpty(editingRows.filter(function (o) {
              return o.key === record.key;
            }));
            var editable = defaultColumn.className === 'editable-cell' || defaultColumn.className === 'editable-cell-operation';
            var isColumnEdited = {
              id: editing && !isUpdate,
              assignLevel: editing,
              // editing && record.organizationId !== 0,
              assignLevelValue: editing && record.assignLevel === 'org' // editing && record.organizationId !== 0 && record.assignLevel === 'org',

            };
            var editableCellProps = {
              title: title,
              text: text,
              dataIndex: dataIndex,
              record: record,
              saveBtnTarget: saveBtnTarget,
              editable: editable,
              editing: isColumnEdited[dataIndex],
              currentEditingRow: _find(editingRows, function (o) {
                return o.key === record.key;
              }),
              roleTenantId: roleDatasource.tenantId,
              roleTenantName: roleDatasource.tenantName,
              setRecord: setRecord,
              // siteMeaning: getCodeMeaning('site', resourceLevel),
              // 角色数据 需要传给 EditCell 来做判断
              roleDatasource: roleDatasource
            };

            if (dataIndex === 'assignLevel') {
              editableCellProps.options = assignResourceLevel(resourceLevel, roleDatasource, record.organizationId, roleDatasource.parentRoleAssignLevel);
            }

            if (dataIndex === 'assignLevelValue') {
              editableCellProps.handleFetchOrganizationData = handleFetchHrunitsTree;
              editableCellProps.roleId = roleDatasource.id;
            }

            if (dataIndex === 'id') {
              editableCellProps.roleId = roleDatasource.id;
            }

            return /*#__PURE__*/React.createElement(EditableContext.Consumer, null, function (form) {
              return defaultColumn.className === 'editable-cell' ? /*#__PURE__*/React.createElement(EditableCell, Object.assign({
                form: form
              }, editableCellProps)) : !_isEmpty(editingRows.filter(function (o) {
                return o.key === record.key;
              })) ? /*#__PURE__*/React.createElement("a", {
                onClick: _this5.cancel.bind(_this5, record, form)
              }, _isInteger(Number(record.key)) ? intl.get("cpaas.common.button.cancel").d('取消') : intl.get("cpaas.common.button.clean").d('清除')) : /*#__PURE__*/React.createElement("a", {
                onClick: _this5.edit.bind(_this5, record, form)
              }, intl.get("cpaas.common.button.edit").d('编辑'));
            });
          }
        }) : defaultColumn;
      };

      return defaultColumns.map(function (n) {
        return getColumn(n);
      });
    }
  }, {
    key: "assignRowData",
    value: function assignRowData(newRecored) {
      var _this$state$dataSourc = this.state.dataSource,
          dataSource = _this$state$dataSourc === void 0 ? [] : _this$state$dataSourc;
      var newDataSource = dataSource.map(function (o) {
        return o.key === newRecored.key ? _objectSpread(_objectSpread({}, o), newRecored) : o;
      });
      this.setState({
        dataSource: newDataSource
      });
    }
  }, {
    key: "getColumns2",
    value: function getColumns2() {
      var _this6 = this;

      var _this$props5 = this.props,
          _this$props5$code = _this$props5.code,
          code = _this$props5$code === void 0 ? {} : _this$props5$code,
          roleDatasource = _this$props5.roleDatasource,
          resourceLevel = _this$props5.resourceLevel,
          _this$props5$handleFe = _this$props5.handleFetchHrunitsTree,
          handleFetchHrunitsTree = _this$props5$handleFe === void 0 ? function () {} : _this$props5$handleFe;
      var editingRows = this.state.editingRows;
      var defaultColumns = [{
        title: intl.get("ciam.roleManagement.model.roleManagement.userLoginName").d('用户名'),
        dataIndex: 'id',
        render: function render(text, record) {
          return record.realName;
        }
      }, !VERSION_IS_OP && currentTenantId === 0 && {
        title: intl.get("ciam.roleManagement.model.roleManagement.tenant").d('所属租户'),
        dataIndex: 'tenantName'
      }, {
        title: intl.get("ciam.roleManagement.model.roleManagement.assignLevel").d('分配层级'),
        dataIndex: 'assignLevel',
        width: 150,
        render: function render(text, record) {
          return record.assignLevelMeaning;
        }
      }, {
        title: intl.get("ciam.roleManagement.model.roleManagement.assignLevelValue").d('分配层级值'),
        dataIndex: 'assignLevelValue',
        width: 180,
        render: function render(text, record) {
          return record.assignLevelValueMeaning;
        }
      }, {
        title: intl.get('cpaas.common.button.action').d('操作'),
        dataIndex: 'action',
        width: 90,
        fixed: 'right',
        render: this.actionRender
      }].filter(Boolean);
      return defaultColumns.map(function (n) {
        return _objectSpread(_objectSpread({}, n), {}, {
          onCell: function onCell(record) {
            var isUpdate = _isInteger(Number(record.key));

            var editing = !_isEmpty(editingRows.filter(function (o) {
              return o.key === record.key;
            }));
            var isColumnEdited = {
              id: editing && !isUpdate,
              assignLevel: editing,
              // editing && record.organizationId !== 0,
              assignLevelValue: editing && record.assignLevel === 'org' // editing && record.organizationId !== 0 && record.assignLevel === 'org',

            };
            var editableCellProps = {
              record: record,
              dataIndex: n.dataIndex,
              title: n.title,
              style: {
                overflow: 'hidden',
                textOverflow: 'ellipsis',
                whiteSpace: 'nowrap'
              },
              assignRowData: _this6.assignRowData,
              onClick: function onClick(e) {
                var target = e.target;

                if (target.style.whiteSpace === 'normal') {
                  target.style.whiteSpace = 'nowrap';
                } else {
                  target.style.whiteSpace = 'normal';
                }
              },
              editing: isColumnEdited[n.dataIndex],
              contextConsumer: EditableContext.Consumer,
              render: n.render,
              code: code,
              roleDatasource: roleDatasource,
              roleTenantId: roleDatasource.tenantId,
              roleTenantName: roleDatasource.tenantName
            };

            if (n.dataIndex === 'assignLevel') {
              editableCellProps.options = assignResourceLevel(resourceLevel, roleDatasource, record.organizationId, roleDatasource.parentRoleAssignLevel);
            }

            if (n.dataIndex === 'assignLevelValue') {
              editableCellProps.handleFetchOrganizationData = handleFetchHrunitsTree;
              editableCellProps.roleId = roleDatasource.id;
            }

            if (n.dataIndex === 'id') {
              editableCellProps.roleId = roleDatasource.id;
            }

            return editableCellProps;
          }
        });
      });
    }
  }, {
    key: "actionRender",
    value: function actionRender(text, record) {
      var _this7 = this;

      var editingRows = this.state.editingRows;
      var operators = [{
        key: 'cancel',
        ele: !_isEmpty(editingRows.filter(function (o) {
          return o.key === record.key;
        })) ? /*#__PURE__*/React.createElement("a", {
          onClick: function onClick() {
            return _this7.cancel(record);
          }
        }, _isInteger(Number(record.key)) ? intl.get("cpaas.common.button.cancel").d('取消') : intl.get("cpaas.common.button.clean").d('清除')) : /*#__PURE__*/React.createElement("a", {
          onClick: function onClick() {
            return _this7.edit(record);
          }
        }, intl.get("cpaas.common.button.edit").d('编辑')),
        len: 2,
        title: !_isEmpty(editingRows.filter(function (o) {
          return o.key === record.key;
        })) ? _isInteger(Number(record.key)) ? intl.get("cpaas.common.button.cancel").d('取消') : intl.get("cpaas.common.button.clean").d('清除') : intl.get("cpaas.common.button.edit").d('编辑')
      }];
      return operatorRender(operators);
    }
  }, {
    key: "edit",
    value: function edit(record) {
      var editingRows = this.state.editingRows;
      this.setState({
        editingRows: _uniqBy(editingRows.concat(_objectSpread({}, record)), 'key')
      });
    }
  }, {
    key: "cancel",
    value: function cancel(record) {
      var _this$state5 = this.state,
          dataSource = _this$state5.dataSource,
          editingRows = _this$state5.editingRows;
      var defaultItem = editingRows.find(function (o) {
        return o.key === record.key;
      });
      this.setState({
        dataSource: _isInteger(record.key) ? dataSource.map(function (n) {
          return n.key === defaultItem.key ? defaultItem : n;
        }) : dataSource.filter(function (o) {
          return o.key !== record.key;
        }),
        editingRows: editingRows.filter(function (o) {
          return o.key !== record.key;
        })
      });
    }
  }, {
    key: "onTableRow",
    value: function onTableRow() {
      var _this8 = this;

      var record = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var _this$props$editableR = this.props.editableRowKey,
          editableRowKey = _this$props$editableR === void 0 ? [] : _this$props$editableR;
      return _objectSpread({
        onRef: function onRef(node) {
          _this8.setTableRowForms(node, record);
        },
        contextProvider: EditableContext.Provider
      }, editableRowKey === record.key ? {
        style: {
          height: 70
        }
      } : {});
    }
    /**
     * setTableRowForms - 设置行缓存
     * @param {!object} node - 表格行this对象
     * @param {object} record - 行数据
     */

  }, {
    key: "setTableRowForms",
    value: function setTableRowForms(node, record) {
      if (_isEmpty(this.tableRowForms)) {
        this.tableRowForms = []; // new Map();
      } // this.tableRowForms = this.tableRowForms.set(record.key, node);


      this.tableRowForms = _uniqBy(this.tableRowForms.concat({
        key: record.key,
        row: node.props.form
      }), 'key');
    }
  }, {
    key: "render",
    value: function render() {
      var _this9 = this;

      var _this$props6 = this.props,
          visible = _this$props6.visible,
          title = _this$props6.title,
          _this$props6$processi = _this$props6.processing,
          processing = _this$props6$processi === void 0 ? {} : _this$props6$processi,
          _this$props6$prompt = _this$props6.prompt,
          prompt = _this$props6$prompt === void 0 ? {} : _this$props6$prompt;
      var _this$state6 = this.state,
          selectedRows = _this$state6.selectedRows,
          dataSource = _this$state6.dataSource,
          pagination = _this$state6.pagination,
          editingRows = _this$state6.editingRows;
      var columns = [{
        title: intl.get("ciam.roleManagement.model.roleManagement.userLoginName").d('用户名'),
        className: 'editable-cell',
        dataIndex: 'id'
      }, !VERSION_IS_OP && currentTenantId === 0 && {
        title: intl.get("ciam.roleManagement.model.roleManagement.tenant").d('所属租户'),
        dataIndex: 'tenantName',
        width: 200
      }, {
        title: intl.get("ciam.roleManagement.model.roleManagement.assignLevel").d('分配层级'),
        dataIndex: 'assignLevel',
        className: 'editable-cell'
      }, {
        title: intl.get("ciam.roleManagement.model.roleManagement.assignLevelValue").d('分配层级值'),
        className: 'editable-cell',
        dataIndex: 'assignLevelValue',
        width: 180
      }, {
        title: intl.get('cpaas.common.button.action').d('操作'),
        dataIndex: 'operation',
        className: 'editable-cell-operation',
        width: 85
      }].filter(Boolean);
      var drawerProps = {
        title: title,
        visible: visible,
        onCancel: this.onDrawerClose.bind(this),
        width: 1000,
        anchor: 'right',
        wrapClassName: styles['ciam-role-members'],
        footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
          onClick: this.onDrawerClose.bind(this),
          disabled: processing.save
        }, intl.get("cpaas.common.button.cancel").d('取消')), !_isEmpty(editingRows) && /*#__PURE__*/React.createElement(Button, {
          ref: function ref(node) {
            _this9.saveBtn = node;
          },
          id: "saveBtn",
          type: "primary",
          loading: processing.save,
          onClick: this.save
        }, intl.get("cpaas.common.button.save").d('保存')))
      };
      var queryFormProps = {
        ref: function ref(node) {
          _this9.queryForm = node;
        },
        prompt: prompt,
        handleFetchData: this.search.bind(this),
        disabled: processing.save,
        loading: processing.query
      };
      var components = {
        body: {
          row: EditableRow,
          // EditableFormRow
          cell: EditableCell
        }
      };
      var tableColumns = this.getColumns.bind(this)(columns);
      var tableProps = {
        components: components,
        pagination: pagination,
        dataSource: dataSource,
        bordered: true,
        className: 'editable-table',
        columns: this.getColumns2(),
        scroll: {
          x: tableScrollWidth(tableColumns)
        },
        loading: processing.query || processing.save,
        rowSelection: {
          selectedRowKeys: selectedRows.map(function (n) {
            return n.key;
          }),
          onChange: this.onTableSelectedRowChange
        },
        onChange: this.onTableChange,
        onRow: this.onTableRow
      };
      return /*#__PURE__*/React.createElement(Drawer, drawerProps, /*#__PURE__*/React.createElement(QueryForm, queryFormProps), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("div", {
        className: "action",
        style: {
          textAlign: 'right'
        }
      }, /*#__PURE__*/React.createElement(Button, {
        onClick: this.deleteRow.bind(this),
        disabled: _isEmpty(selectedRows) || processing.delete || processing.save || processing.query,
        style: {
          marginRight: 8
        }
      }, intl.get("cpaas.common.button.delete").d('删除')), /*#__PURE__*/React.createElement(Button, {
        type: "primary",
        onClick: this.add.bind(this),
        disabled: processing.delete || processing.save || processing.query
      }, intl.get("cpaas.common.button.add").d('新增'))), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Table, tableProps));
    }
  }]);

  return Members;
}(PureComponent), (_applyDecoratedDescriptor(_class.prototype, "onTableSelectedRowChange", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "onTableSelectedRowChange"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onTableChange", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "onTableChange"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "save", [_dec3], Object.getOwnPropertyDescriptor(_class.prototype, "save"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "assignRowData", [_dec4], Object.getOwnPropertyDescriptor(_class.prototype, "assignRowData"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getColumns2", [_dec5], Object.getOwnPropertyDescriptor(_class.prototype, "getColumns2"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "actionRender", [_dec6], Object.getOwnPropertyDescriptor(_class.prototype, "actionRender"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "edit", [_dec7], Object.getOwnPropertyDescriptor(_class.prototype, "edit"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "cancel", [_dec8], Object.getOwnPropertyDescriptor(_class.prototype, "cancel"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onTableRow", [_dec9], Object.getOwnPropertyDescriptor(_class.prototype, "onTableRow"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "setTableRowForms", [_dec10], Object.getOwnPropertyDescriptor(_class.prototype, "setTableRowForms"), _class.prototype)), _class));
export { Members as default };